home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / MacTCP.h < prev    next >
Text File  |  1995-07-06  |  25KB  |  854 lines

  1. /*
  2.      File:        MacTCP.h
  3.  
  4.      Contains:    TCP Manager Interfaces.
  5.  
  6.      Version:    Technology:    MacTCP 2.0.6
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __MACTCP__
  21. #define __MACTCP__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __APPLETALK__
  30. #include <AppleTalk.h>
  31. #endif
  32. /*    #include <OSUtils.h>                                        */
  33. /*        #include <MixedMode.h>                                    */
  34. /*        #include <Memory.h>                                        */
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_ALIGN_SUPPORTED
  41. #pragma options align=mac68k
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT_SUPPORTED
  45. #pragma import on
  46. #endif
  47.  
  48. /*
  49. Developer Notes:
  50.         0. This MacTCP header replaces what used to be defined in the following header files
  51.             MacTCPCommonTypes.h
  52.             GetMyIPAddr.h
  53.             MiscIPPB.h
  54.             TCPPB.h
  55.             UDPPB.h 
  56.             
  57.             When the various control calls are made to the ip driver, you must set up a 
  58.             NewRoutineDescriptor for every non-nil completion routine and/or notifyProc parameter.  
  59.             Otherwise, the 68K driver code, will not correctly call your routine.
  60.         1. For ipctlGetAddr Control calls, use NewGetIPIOCompletionProc
  61.             to set up a GetIPIOCompletionUPP universal procptr to pass as
  62.             the ioCompletion parameter.
  63.         2. For the ipctlEchoICMP and ipctlLAPStats Control calls, use 
  64.             NewIPIOCompletion to set up a IPIOCompletionUPP universal procptr
  65.             to pass in the ioCompletion field of the parameter block.
  66.         3. For TCPCreatePB Control calls, use NewTCPNotifyProc to set up a
  67.             TCPNotifyUPP universal procptr to pass in the notifyProc field
  68.             of the parameter block
  69.         4. For all of the TCP Control calls using the TCPiopb parameter block,
  70.             use NewTCPIOCompletionProc to set up a TCPIOCompletionUPP
  71.             universal procptr to pass in the ioCompletion field of the paramter
  72.             block.
  73.         5. For UDBCreatePB Control calls, use NewUDPNotifyProc to set up a
  74.             UDPNotifyUPP universal procptr to pass in the notifyProc field
  75.             of the parameter block
  76.         6. For all of the UDP Control calls using the UDPiopb parameter block,
  77.             use NewUDPIOCompletionProc to set up a UDPIOCompletionUPP
  78.             universal procptr to pass in the ioCompletion field of the paramter
  79.             block.
  80.         7. For all calls implementing a notifyProc or ioCompletion routine
  81.             which was set up using a NewTCPRoutineProc call, do not call
  82.             DisposeRoutineSDescriptor on the universal procptr until
  83.             after the completion or notify proc has completed.
  84. */
  85. /* MacTCP return Codes in the range -23000 through -23049 */
  86.  
  87. enum {
  88.     inProgress                    = 1,                            /* I/O in progress */
  89.     ipBadLapErr                    = -23000,                        /* bad network configuration */
  90.     ipBadCnfgErr                = -23001,                        /* bad IP configuration error */
  91.     ipNoCnfgErr                    = -23002,                        /* missing IP or LAP configuration error */
  92.     ipLoadErr                    = -23003,                        /* error in MacTCP load */
  93.     ipBadAddr                    = -23004,                        /* error in getting address */
  94.     connectionClosing            = -23005,                        /* connection is closing */
  95.     invalidLength                = -23006,
  96.     connectionExists            = -23007,                        /* request conflicts with existing connection */
  97.     connectionDoesntExist        = -23008,                        /* connection does not exist */
  98.     insufficientResources        = -23009,                        /* insufficient resources to perform request */
  99.     invalidStreamPtr            = -23010,
  100.     streamAlreadyOpen            = -23011,
  101.     connectionTerminated        = -23012,
  102.     invalidBufPtr                = -23013,
  103.     invalidRDS                    = -23014,
  104.     invalidWDS                    = -23014,
  105.     openFailed                    = -23015,
  106.     commandTimeout                = -23016,
  107.     duplicateSocket                = -23017
  108. };
  109.  
  110. /* Error codes from internal IP functions */
  111. enum {
  112.     ipDontFragErr                = -23032,                        /* Packet too large to send w/o fragmenting */
  113.     ipDestDeadErr                = -23033,                        /* destination not responding */
  114.     icmpEchoTimeoutErr            = -23035,                        /* ICMP echo timed-out */
  115.     ipNoFragMemErr                = -23036,                        /* no memory to send fragmented pkt */
  116.     ipRouteErr                    = -23037,                        /* can't route packet off-net */
  117.     nameSyntaxErr                = -23041,
  118.     cacheFault                    = -23042,
  119.     noResultProc                = -23043,
  120.     noNameServer                = -23044,
  121.     authNameErr                    = -23045,
  122.     noAnsErr                    = -23046,
  123.     dnrErr                        = -23047,
  124.     outOfMemory                    = -23048
  125. };
  126.  
  127. enum {
  128.     BYTES_16WORD                = 2,                            /* bytes per = 16, bit ip word */
  129.     BYTES_32WORD                = 4,                            /* bytes per = 32, bit ip word */
  130.     BYTES_64WORD                = 8                                /* bytes per = 64, bit ip word */
  131. };
  132.  
  133. /* 8-bit quantity */
  134. typedef UInt8 b_8;
  135.  
  136. /* 16-bit quantity */
  137. typedef UInt16 b_16;
  138.  
  139. /* 32-bit quantity */
  140. typedef UInt32 b_32;
  141.  
  142. /* IP address is 32-bits */
  143. typedef b_32 ip_addr;
  144.  
  145. struct ip_addrbytes {
  146.     union {
  147.         b_32                            addr;
  148.         UInt8                            byte[4];
  149.     }                                a;
  150. };
  151. typedef struct ip_addrbytes ip_addrbytes;
  152.  
  153. struct wdsEntry {
  154.     unsigned short                    length;                        /* length of buffer */
  155.     Ptr                                ptr;                        /* pointer to buffer */
  156. };
  157. typedef struct wdsEntry wdsEntry;
  158.  
  159. struct rdsEntry {
  160.     unsigned short                    length;                        /* length of buffer */
  161.     Ptr                                ptr;                        /* pointer to buffer */
  162. };
  163. typedef struct rdsEntry rdsEntry;
  164.  
  165. typedef unsigned long BufferPtr;
  166.  
  167. typedef unsigned long StreamPtr;
  168.  
  169.  
  170. enum {
  171.     netUnreach                    = 0,
  172.     hostUnreach                    = 1,
  173.     protocolUnreach                = 2,
  174.     portUnreach                    = 3,
  175.     fragReqd                    = 4,
  176.     sourceRouteFailed            = 5,
  177.     timeExceeded                = 6,
  178.     parmProblem                    = 7,
  179.     missingOption                = 8,
  180.     lastICMPMsgType                = 32767
  181. };
  182.  
  183. typedef unsigned short ICMPMsgType;
  184.  
  185. typedef b_16 ip_port;
  186.  
  187. struct ICMPReport {
  188.     StreamPtr                        streamPtr;
  189.     ip_addr                            localHost;
  190.     ip_port                            localPort;
  191.     ip_addr                            remoteHost;
  192.     ip_port                            remotePort;
  193.     short                            reportType;
  194.     unsigned short                    optionalAddlInfo;
  195.     unsigned long                    optionalAddlInfoPtr;
  196. };
  197. typedef struct ICMPReport ICMPReport;
  198.  
  199. /* csCode to get our IP address */
  200.  
  201. enum {
  202.     ipctlGetAddr                = 15
  203. };
  204.  
  205. typedef void (*GetIPIOCompletionProcPtr)(struct GetAddrParamBlock *iopb);
  206.  
  207. #if GENERATINGCFM
  208. typedef UniversalProcPtr GetIPIOCompletionUPP;
  209. #else
  210. typedef GetIPIOCompletionProcPtr GetIPIOCompletionUPP;
  211. #endif
  212.  
  213. #define GetIPParamBlockHeader     \
  214.     struct QElem*    qLink;         \
  215.     short    qType;                 \
  216.     short    ioTrap;                 \
  217.     Ptr    ioCmdAddr;                 \
  218.     GetIPIOCompletionUPP    ioCompletion;  \
  219.     OSErr    ioResult;             \
  220.     StringPtr    ioNamePtr;         \
  221.     short    ioVRefNum;                \
  222.     short    ioCRefNum;                \
  223.     short    csCode
  224. struct GetAddrParamBlock {
  225.     struct QElem                    *qLink;
  226.     short                            qType;
  227.     short                            ioTrap;
  228.     Ptr                                ioCmdAddr;
  229.     GetIPIOCompletionUPP            ioCompletion;
  230.     OSErr                            ioResult;
  231.     StringPtr                        ioNamePtr;
  232.     short                            ioVRefNum;
  233.     short                            ioCRefNum;
  234.     short                            csCode;                        /* standard I/O header */
  235.     ip_addr                            ourAddress;                    /* our IP address */
  236.     long                            ourNetMask;                    /* our IP net mask */
  237. };
  238. typedef struct GetAddrParamBlock GetAddrParamBlock;
  239.  
  240. /* control codes */
  241.  
  242. enum {
  243.     ipctlEchoICMP                = 17,                            /* send icmp echo */
  244.     ipctlLAPStats                = 19                            /* get lap stats */
  245. };
  246.  
  247. typedef void (*IPIOCompletionProcPtr)(struct ICMPParamBlock *iopb);
  248.  
  249. #if GENERATINGCFM
  250. typedef UniversalProcPtr IPIOCompletionUPP;
  251. #else
  252. typedef IPIOCompletionProcPtr IPIOCompletionUPP;
  253. #endif
  254.  
  255. #define IPParamBlockHeader         \
  256.     struct QElem*    qLink;         \
  257.     short    qType;                 \
  258.     short    ioTrap;                 \
  259.     Ptr    ioCmdAddr;                 \
  260.     IPIOCompletionUPP    ioCompletion;  \
  261.     OSErr    ioResult;             \
  262.     StringPtr    ioNamePtr;         \
  263.     short    ioVRefNum;                \
  264.     short    ioCRefNum;                \
  265.     short    csCode
  266. struct ICMPParamBlock {
  267.     struct QElem                    *qLink;
  268.     short                            qType;
  269.     short                            ioTrap;
  270.     Ptr                                ioCmdAddr;
  271.     IPIOCompletionUPP                ioCompletion;
  272.     OSErr                            ioResult;
  273.     StringPtr                        ioNamePtr;
  274.     short                            ioVRefNum;
  275.     short                            ioCRefNum;
  276.     short                            csCode;                        /* standard I/O header */
  277.     short                            params[11];
  278.     struct {
  279.         unsigned long                    echoRequestOut;            /* time in ticks of when the echo request went out */
  280.         unsigned long                    echoReplyIn;            /* time in ticks of when the reply was received */
  281.         struct rdsEntry                    echoedData;                /* data received in responce */
  282.         Ptr                                options;
  283.         unsigned long                    userDataPtr;
  284.     }                                icmpEchoInfo;
  285. };
  286. typedef pascal void (*ICMPEchoNotifyProcPtr)(struct ICMPParamBlock *iopb);
  287.  
  288. #if GENERATINGCFM
  289. typedef UniversalProcPtr ICMPEchoNotifyUPP;
  290. #else
  291. typedef ICMPEchoNotifyProcPtr ICMPEchoNotifyUPP;
  292. #endif
  293.  
  294. struct IPParamBlock {
  295.     struct QElem                    *qLink;
  296.     short                            qType;
  297.     short                            ioTrap;
  298.     Ptr                                ioCmdAddr;
  299.     IPIOCompletionUPP                ioCompletion;
  300.     OSErr                            ioResult;
  301.     StringPtr                        ioNamePtr;
  302.     short                            ioVRefNum;
  303.     short                            ioCRefNum;
  304.     short                            csCode;                        /* standard I/O header */
  305.     union {
  306.         struct {
  307.             ip_addr                            dest;                /* echo to IP address */
  308.             wdsEntry                        data;
  309.             short                            timeout;
  310.             Ptr                                options;
  311.             unsigned short                    optLength;
  312.             ICMPEchoNotifyUPP                icmpCompletion;
  313.             unsigned long                    userDataPtr;
  314.         }                                IPEchoPB;
  315.         struct {
  316.             struct LAPStats                    *lapStatsPtr;
  317.         }                                LAPStatsPB;
  318.     }                                csParam;
  319. };
  320. union LAPStatsAddrXlation {
  321.     struct arp_entry                *arp_table;
  322.     struct nbp_entry                *nbp_table;
  323. };
  324. struct LAPStats {
  325.     short                            ifType;
  326.     char                            *ifString;
  327.     short                            ifMaxMTU;
  328.     long                            ifSpeed;
  329.     short                            ifPhyAddrLength;
  330.     char                            *ifPhysicalAddress;
  331.     union LAPStatsAddrXlation        AddrXlation;
  332.     short                            slotNumber;
  333. };
  334. typedef struct LAPStats LAPStats;
  335.  
  336. struct nbp_entry {
  337.     ip_addr                            ip_address;                    /* IP address */
  338.     AddrBlock                        at_address;                    /* matching AppleTalk address */
  339.     Boolean                            gateway;                    /* TRUE if entry for a gateway */
  340.     Boolean                            valid;                        /* TRUE if LAP address is valid */
  341.     Boolean                            probing;                    /* TRUE if NBP lookup pending */
  342.     SInt8                            afiller;                    /* Filler for proper byte alignment     */
  343.     long                            age;                        /* ticks since cache entry verified */
  344.     long                            access;                        /* ticks since last access */
  345.     SInt8                            filler[116];                /* for internal use only !!! */
  346. };
  347. struct Enet_addr {
  348.     b_16                            en_hi;
  349.     b_32                            en_lo;
  350. };
  351. typedef struct Enet_addr Enet_addr;
  352.  
  353. struct arp_entry {
  354.     short                            age;                        /* cache aging field */
  355.     b_16                            protocol;                    /* Protocol type */
  356.     ip_addr                            ip_address;                    /* IP address */
  357.     Enet_addr                        en_address;                    /* matching Ethernet address */
  358. };
  359. typedef struct arp_entry arp_entry;
  360.  
  361. /* number of ARP table entries */
  362.  
  363. enum {
  364.     ARP_TABLE_SIZE                = 20
  365. };
  366.  
  367. enum {
  368.     NBP_TABLE_SIZE                = 20,                            /* number of NBP table entries */
  369.     NBP_MAX_NAME_SIZE            = 16 + 10 + 2
  370. };
  371.  
  372. /* Command codes */
  373. enum {
  374.     TCPCreate                    = 30,
  375.     TCPPassiveOpen                = 31,
  376.     TCPActiveOpen                = 32,
  377.     TCPSend                        = 34,
  378.     TCPNoCopyRcv                = 35,
  379.     TCPRcvBfrReturn                = 36,
  380.     TCPRcv                        = 37,
  381.     TCPClose                    = 38,
  382.     TCPAbort                    = 39,
  383.     TCPStatus                    = 40,
  384.     TCPExtendedStat                = 41,
  385.     TCPRelease                    = 42,
  386.     TCPGlobalInfo                = 43,
  387.     TCPCtlMax                    = 49
  388. };
  389.  
  390. enum {
  391.     TCPClosing                    = 1,
  392.     TCPULPTimeout                = 2,
  393.     TCPTerminate                = 3,
  394.     TCPDataArrival                = 4,
  395.     TCPUrgent                    = 5,
  396.     TCPICMPReceived                = 6,
  397.     lastEvent                    = 32767
  398. };
  399.  
  400. typedef unsigned short TCPEventCode;
  401.  
  402.  
  403. enum {
  404.     TCPRemoteAbort                = 2,
  405.     TCPNetworkFailure            = 3,
  406.     TCPSecPrecMismatch            = 4,
  407.     TCPULPTimeoutTerminate        = 5,
  408.     TCPULPAbort                    = 6,
  409.     TCPULPClose                    = 7,
  410.     TCPServiceError                = 8,
  411.     lastReason                    = 32767
  412. };
  413.  
  414. typedef unsigned short TCPTerminationReason;
  415.  
  416. typedef pascal void (*TCPNotifyProcPtr)(StreamPtr tcpStream, unsigned short eventCode, Ptr userDataPtr, unsigned short terminReason, struct ICMPReport *icmpMsg);
  417.  
  418. #if GENERATINGCFM
  419. typedef UniversalProcPtr TCPNotifyUPP;
  420. #else
  421. typedef TCPNotifyProcPtr TCPNotifyUPP;
  422. #endif
  423.  
  424. typedef unsigned short tcp_port;
  425.  
  426. /* ValidityFlags */
  427.  
  428. enum {
  429.     timeoutValue                = 0x80,
  430.     timeoutAction                = 0x40,
  431.     typeOfService                = 0x20,
  432.     precedence                    = 0x10
  433. };
  434.  
  435. /* TOSFlags */
  436. enum {
  437.     lowDelay                    = 0x01,
  438.     throughPut                    = 0x02,
  439.     reliability                    = 0x04
  440. };
  441.  
  442. struct TCPCreatePB {
  443.     Ptr                                rcvBuff;
  444.     unsigned long                    rcvBuffLen;
  445.     TCPNotifyUPP                    notifyProc;
  446.     Ptr                                userDataPtr;
  447. };
  448. typedef struct TCPCreatePB TCPCreatePB;
  449.  
  450. struct TCPOpenPB {
  451.     SInt8                            ulpTimeoutValue;
  452.     SInt8                            ulpTimeoutAction;
  453.     SInt8                            validityFlags;
  454.     SInt8                            commandTimeoutValue;
  455.     ip_addr                            remoteHost;
  456.     tcp_port                        remotePort;
  457.     ip_addr                            localHost;
  458.     tcp_port                        localPort;
  459.     SInt8                            tosFlags;
  460.     SInt8                            precedence;
  461.     Boolean                            dontFrag;
  462.     SInt8                            timeToLive;
  463.     SInt8                            security;
  464.     SInt8                            optionCnt;
  465.     SInt8                            options[40];
  466.     Ptr                                userDataPtr;
  467. };
  468. typedef struct TCPOpenPB TCPOpenPB;
  469.  
  470. struct TCPSendPB {
  471.     SInt8                            ulpTimeoutValue;
  472.     SInt8                            ulpTimeoutAction;
  473.     SInt8                            validityFlags;
  474.     Boolean                            pushFlag;
  475.     Boolean                            urgentFlag;
  476.     SInt8                            filler;                        /* Filler for proper byte alignment     */
  477.     Ptr                                wdsPtr;
  478.     unsigned long                    sendFree;
  479.     unsigned short                    sendLength;
  480.     Ptr                                userDataPtr;
  481. };
  482. typedef struct TCPSendPB TCPSendPB;
  483.  
  484. /* for receive and return rcv buff calls */
  485. /*   Note: the filler in the following structure is in a different location than */
  486. /*         that specified in the Programmer's Guide.  */
  487. struct TCPReceivePB {
  488.     SInt8                            commandTimeoutValue;
  489.     Boolean                            markFlag;
  490.     Boolean                            urgentFlag;
  491.     SInt8                            filler;                        /* Filler for proper byte alignment  */
  492.     Ptr                                rcvBuff;
  493.     unsigned short                    rcvBuffLen;
  494.     Ptr                                rdsPtr;
  495.     unsigned short                    rdsLength;
  496.     unsigned short                    secondTimeStamp;
  497.     Ptr                                userDataPtr;
  498. };
  499. typedef struct TCPReceivePB TCPReceivePB;
  500.  
  501. struct TCPClosePB {
  502.     SInt8                            ulpTimeoutValue;
  503.     SInt8                            ulpTimeoutAction;
  504.     SInt8                            validityFlags;
  505.     SInt8                            filler;                        /* Filler for proper byte alignment     */
  506.     Ptr                                userDataPtr;
  507. };
  508. typedef struct TCPClosePB TCPClosePB;
  509.  
  510. struct HistoBucket {
  511.     unsigned short                    value;
  512.     unsigned long                    counter;
  513. };
  514. typedef struct HistoBucket HistoBucket;
  515.  
  516.  
  517. enum {
  518.     NumOfHistoBuckets            = 7
  519. };
  520.  
  521. struct TCPConnectionStats {
  522.     unsigned long                    dataPktsRcvd;
  523.     unsigned long                    dataPktsSent;
  524.     unsigned long                    dataPktsResent;
  525.     unsigned long                    bytesRcvd;
  526.     unsigned long                    bytesRcvdDup;
  527.     unsigned long                    bytesRcvdPastWindow;
  528.     unsigned long                    bytesSent;
  529.     unsigned long                    bytesResent;
  530.     unsigned short                    numHistoBuckets;
  531.     struct HistoBucket                sentSizeHisto[NumOfHistoBuckets];
  532.     unsigned short                    lastRTT;
  533.     unsigned short                    tmrSRTT;
  534.     unsigned short                    rttVariance;
  535.     unsigned short                    tmrRTO;
  536.     SInt8                            sendTries;
  537.     SInt8                            sourchQuenchRcvd;
  538. };
  539. typedef struct TCPConnectionStats TCPConnectionStats;
  540.  
  541. struct TCPStatusPB {
  542.     SInt8                            ulpTimeoutValue;
  543.     SInt8                            ulpTimeoutAction;
  544.     long                            unused;
  545.     ip_addr                            remoteHost;
  546.     tcp_port                        remotePort;
  547.     ip_addr                            localHost;
  548.     tcp_port                        localPort;
  549.     SInt8                            tosFlags;
  550.     SInt8                            precedence;
  551.     SInt8                            connectionState;
  552.     SInt8                            filler;                        /* Filler for proper byte alignment     */
  553.     unsigned short                    sendWindow;
  554.     unsigned short                    rcvWindow;
  555.     unsigned short                    amtUnackedData;
  556.     unsigned short                    amtUnreadData;
  557.     Ptr                                securityLevelPtr;
  558.     unsigned long                    sendUnacked;
  559.     unsigned long                    sendNext;
  560.     unsigned long                    congestionWindow;
  561.     unsigned long                    rcvNext;
  562.     unsigned long                    srtt;
  563.     unsigned long                    lastRTT;
  564.     unsigned long                    sendMaxSegSize;
  565.     struct TCPConnectionStats        *connStatPtr;
  566.     Ptr                                userDataPtr;
  567. };
  568. typedef struct TCPStatusPB TCPStatusPB;
  569.  
  570. struct TCPAbortPB {
  571.     Ptr                                userDataPtr;
  572. };
  573. typedef struct TCPAbortPB TCPAbortPB;
  574.  
  575. struct TCPParam {
  576.     unsigned long                    tcpRtoA;
  577.     unsigned long                    tcpRtoMin;
  578.     unsigned long                    tcpRtoMax;
  579.     unsigned long                    tcpMaxSegSize;
  580.     unsigned long                    tcpMaxConn;
  581.     unsigned long                    tcpMaxWindow;
  582. };
  583. typedef struct TCPParam TCPParam;
  584.  
  585. struct TCPStats {
  586.     unsigned long                    tcpConnAttempts;
  587.     unsigned long                    tcpConnOpened;
  588.     unsigned long                    tcpConnAccepted;
  589.     unsigned long                    tcpConnClosed;
  590.     unsigned long                    tcpConnAborted;
  591.     unsigned long                    tcpOctetsIn;
  592.     unsigned long                    tcpOctetsOut;
  593.     unsigned long                    tcpOctetsInDup;
  594.     unsigned long                    tcpOctetsRetrans;
  595.     unsigned long                    tcpInputPkts;
  596.     unsigned long                    tcpOutputPkts;
  597.     unsigned long                    tcpDupPkts;
  598.     unsigned long                    tcpRetransPkts;
  599. };
  600. typedef struct TCPStats TCPStats;
  601.  
  602. typedef StreamPtr *StreamPPtr;
  603.  
  604. struct TCPGlobalInfoPB {
  605.     struct TCPParam                    *tcpParamPtr;
  606.     struct TCPStats                    *tcpStatsPtr;
  607.     StreamPPtr                        tcpCDBTable[1];
  608.     Ptr                                userDataPtr;
  609.     unsigned short                    maxTCPConnections;
  610. };
  611. typedef struct TCPGlobalInfoPB TCPGlobalInfoPB;
  612.  
  613. typedef void (*TCPIOCompletionProcPtr)(struct TCPiopb *iopb);
  614.  
  615. #if GENERATINGCFM
  616. typedef UniversalProcPtr TCPIOCompletionUPP;
  617. #else
  618. typedef TCPIOCompletionProcPtr TCPIOCompletionUPP;
  619. #endif
  620.  
  621. struct TCPiopb {
  622.     SInt8                            fill12[12];
  623.     TCPIOCompletionUPP                ioCompletion;
  624.     short                            ioResult;
  625.     Ptr                                ioNamePtr;
  626.     short                            ioVRefNum;
  627.     short                            ioCRefNum;
  628.     short                            csCode;
  629.     StreamPtr                        tcpStream;
  630.     union {
  631.         struct TCPCreatePB                create;
  632.         struct TCPOpenPB                open;
  633.         struct TCPSendPB                send;
  634.         struct TCPReceivePB                receive;
  635.         struct TCPClosePB                close;
  636.         struct TCPAbortPB                abort;
  637.         struct TCPStatusPB                status;
  638.         struct TCPGlobalInfoPB            globalInfo;
  639.     }                                csParam;
  640. };
  641. typedef struct TCPiopb TCPiopb;
  642.  
  643.  
  644. enum {
  645.     UDPCreate                    = 20,
  646.     UDPRead                        = 21,
  647.     UDPBfrReturn                = 22,
  648.     UDPWrite                    = 23,
  649.     UDPRelease                    = 24,
  650.     UDPMaxMTUSize                = 25,
  651.     UDPStatus                    = 26,
  652.     UDPMultiCreate                = 27,
  653.     UDPMultiSend                = 28,
  654.     UDPMultiRead                = 29,
  655.     UDPCtlMax                    = 29
  656. };
  657.  
  658. enum {
  659.     UDPDataArrival                = 1,
  660.     UDPICMPReceived                = 2,
  661.     lastUDPEvent                = 32767
  662. };
  663.  
  664. typedef unsigned short UDPEventCode;
  665.  
  666. typedef pascal void (*UDPNotifyProcPtr)(StreamPtr udpStream, unsigned short eventCode, Ptr userDataPtr, struct ICMPReport *icmpMsg);
  667.  
  668. #if GENERATINGCFM
  669. typedef UniversalProcPtr UDPNotifyUPP;
  670. #else
  671. typedef UDPNotifyProcPtr UDPNotifyUPP;
  672. #endif
  673.  
  674. typedef unsigned short udp_port;
  675.  
  676. /* for create and release calls */
  677. struct UDPCreatePB {
  678.     Ptr                                rcvBuff;
  679.     unsigned long                    rcvBuffLen;
  680.     UDPNotifyUPP                    notifyProc;
  681.     unsigned short                    localPort;
  682.     Ptr                                userDataPtr;
  683.     udp_port                        endingPort;
  684. };
  685. typedef struct UDPCreatePB UDPCreatePB;
  686.  
  687. struct UDPSendPB {
  688.     unsigned short                    reserved;
  689.     ip_addr                            remoteHost;
  690.     udp_port                        remotePort;
  691.     Ptr                                wdsPtr;
  692.     Boolean                            checkSum;
  693.     SInt8                            filler;                        /* Filler for proper byte alignment     */
  694.     unsigned short                    sendLength;
  695.     Ptr                                userDataPtr;
  696.     udp_port                        localPort;
  697. };
  698. typedef struct UDPSendPB UDPSendPB;
  699.  
  700. /* for receive and buffer return calls */
  701. struct UDPReceivePB {
  702.     unsigned short                    timeOut;
  703.     ip_addr                            remoteHost;
  704.     udp_port                        remotePort;
  705.     Ptr                                rcvBuff;
  706.     unsigned short                    rcvBuffLen;
  707.     unsigned short                    secondTimeStamp;
  708.     Ptr                                userDataPtr;
  709.     ip_addr                            destHost;                    /* only for use with multi rcv */
  710.     udp_port                        destPort;                    /* only for use with multi rcv */
  711. };
  712. typedef struct UDPReceivePB UDPReceivePB;
  713.  
  714. struct UDPMTUPB {
  715.     unsigned short                    mtuSize;
  716.     ip_addr                            remoteHost;
  717.     Ptr                                userDataPtr;
  718. };
  719. typedef struct UDPMTUPB UDPMTUPB;
  720.  
  721. typedef void (*UDPIOCompletionProcPtr)(struct UDPiopb *iopb);
  722.  
  723. #if GENERATINGCFM
  724. typedef UniversalProcPtr UDPIOCompletionUPP;
  725. #else
  726. typedef UDPIOCompletionProcPtr UDPIOCompletionUPP;
  727. #endif
  728.  
  729. struct UDPiopb {
  730.     SInt8                            fill12[12];
  731.     UDPIOCompletionUPP                ioCompletion;
  732.     short                            ioResult;
  733.     Ptr                                ioNamePtr;
  734.     short                            ioVRefNum;
  735.     short                            ioCRefNum;
  736.     short                            csCode;
  737.     StreamPtr                        udpStream;
  738.     union {
  739.         struct UDPCreatePB                create;
  740.         struct UDPSendPB                send;
  741.         struct UDPReceivePB                receive;
  742.         struct UDPMTUPB                    mtu;
  743.     }                                csParam;
  744. };
  745. typedef struct UDPiopb UDPiopb;
  746.  
  747.  
  748. #if GENERATINGCFM
  749. #else
  750. #endif
  751.  
  752. enum {
  753.     uppGetIPIOCompletionProcInfo = kCStackBased
  754.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct GetAddrParamBlock*))),
  755.     uppIPIOCompletionProcInfo = kCStackBased
  756.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct ICMPParamBlock*))),
  757.     uppICMPEchoNotifyProcInfo = kPascalStackBased
  758.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct ICMPParamBlock*))),
  759.     uppTCPNotifyProcInfo = kPascalStackBased
  760.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(StreamPtr)))
  761.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned short)))
  762.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr)))
  763.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned short)))
  764.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(struct ICMPReport*))),
  765.     uppTCPIOCompletionProcInfo = kCStackBased
  766.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct TCPiopb*))),
  767.     uppUDPNotifyProcInfo = kPascalStackBased
  768.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(StreamPtr)))
  769.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned short)))
  770.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr)))
  771.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(struct ICMPReport*))),
  772.     uppUDPIOCompletionProcInfo = kCStackBased
  773.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct UDPiopb*)))
  774. };
  775.  
  776. #if GENERATINGCFM
  777. #define NewGetIPIOCompletionProc(userRoutine)        \
  778.         (GetIPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, GetCurrentArchitecture())
  779. #define NewIPIOCompletionProc(userRoutine)        \
  780.         (IPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppIPIOCompletionProcInfo, GetCurrentArchitecture())
  781. #define NewICMPEchoNotifyProc(userRoutine)        \
  782.         (ICMPEchoNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, GetCurrentArchitecture())
  783. #define NewTCPNotifyProc(userRoutine)        \
  784.         (TCPNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPNotifyProcInfo, GetCurrentArchitecture())
  785. #define NewTCPIOCompletionProc(userRoutine)        \
  786.         (TCPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, GetCurrentArchitecture())
  787. #define NewUDPNotifyProc(userRoutine)        \
  788.         (UDPNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPNotifyProcInfo, GetCurrentArchitecture())
  789. #define NewUDPIOCompletionProc(userRoutine)        \
  790.         (UDPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, GetCurrentArchitecture())
  791. #else
  792. #define NewGetIPIOCompletionProc(userRoutine)        \
  793.         ((GetIPIOCompletionUPP) (userRoutine))
  794. #define NewIPIOCompletionProc(userRoutine)        \
  795.         ((IPIOCompletionUPP) (userRoutine))
  796. #define NewICMPEchoNotifyProc(userRoutine)        \
  797.         ((ICMPEchoNotifyUPP) (userRoutine))
  798. #define NewTCPNotifyProc(userRoutine)        \
  799.         ((TCPNotifyUPP) (userRoutine))
  800. #define NewTCPIOCompletionProc(userRoutine)        \
  801.         ((TCPIOCompletionUPP) (userRoutine))
  802. #define NewUDPNotifyProc(userRoutine)        \
  803.         ((UDPNotifyUPP) (userRoutine))
  804. #define NewUDPIOCompletionProc(userRoutine)        \
  805.         ((UDPIOCompletionUPP) (userRoutine))
  806. #endif
  807.  
  808. #if GENERATINGCFM
  809. #define CallGetIPIOCompletionProc(userRoutine, iopb)        \
  810.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, (iopb))
  811. #define CallIPIOCompletionProc(userRoutine, iopb)        \
  812.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppIPIOCompletionProcInfo, (iopb))
  813. #define CallICMPEchoNotifyProc(userRoutine, iopb)        \
  814.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, (iopb))
  815. #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg)        \
  816.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTCPNotifyProcInfo, (tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
  817. #define CallTCPIOCompletionProc(userRoutine, iopb)        \
  818.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, (iopb))
  819. #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg)        \
  820.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppUDPNotifyProcInfo, (udpStream), (eventCode), (userDataPtr), (icmpMsg))
  821. #define CallUDPIOCompletionProc(userRoutine, iopb)        \
  822.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, (iopb))
  823. #else
  824. #define CallGetIPIOCompletionProc(userRoutine, iopb)        \
  825.         (*(userRoutine))((iopb))
  826. #define CallIPIOCompletionProc(userRoutine, iopb)        \
  827.         (*(userRoutine))((iopb))
  828. #define CallICMPEchoNotifyProc(userRoutine, iopb)        \
  829.         (*(userRoutine))((iopb))
  830. #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg)        \
  831.         (*(userRoutine))((tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
  832. #define CallTCPIOCompletionProc(userRoutine, iopb)        \
  833.         (*(userRoutine))((iopb))
  834. #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg)        \
  835.         (*(userRoutine))((udpStream), (eventCode), (userDataPtr), (icmpMsg))
  836. #define CallUDPIOCompletionProc(userRoutine, iopb)        \
  837.         (*(userRoutine))((iopb))
  838. #endif
  839.  
  840.  
  841. #if PRAGMA_IMPORT_SUPPORTED
  842. #pragma import off
  843. #endif
  844.  
  845. #if PRAGMA_ALIGN_SUPPORTED
  846. #pragma options align=reset
  847. #endif
  848.  
  849. #ifdef __cplusplus
  850. }
  851. #endif
  852.  
  853. #endif /* __MACTCP__ */
  854.